package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.PayGateint;
import com.pgybook.db.entity.domain.PayGateintEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface PayGateintMapper {
    int countByExample(PayGateintEx example);

    int deleteByExample(PayGateintEx example);

    @Delete({
            "delete from paygateint",
            "where TRADENO = #{tradeno,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String tradeno);

    @Insert({
            "insert into paygateint (CUSTID, STATUS, ",
            "SUBJECT, TYPE, TOTALFEE, ",
            "PAYCOMPANYID, REQTIME, ",
            "REQCONTENT, RESTIME, ",
            "RESCONTENT, THIRDTRADENO, ",
            "NOTIFYID)",
            "values (#{custid,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, ",
            "#{subject,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{totalfee,jdbcType=DECIMAL}, ",
            "#{paycompanyid,jdbcType=INTEGER}, #{reqtime,jdbcType=TIMESTAMP}, ",
            "#{reqcontent,jdbcType=VARCHAR}, #{restime,jdbcType=TIMESTAMP}, ",
            "#{rescontent,jdbcType=VARCHAR}, #{thirdtradeno,jdbcType=VARCHAR}, ",
            "#{notifyid,jdbcType=VARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "tradeno", before = false, resultType = String.class)
    int insert(PayGateint record);

    int insertSelective(PayGateint record);

    List<PayGateint> selectByExample(PayGateintEx example);

    @Select({
            "select",
            "TRADENO, CUSTID, STATUS, SUBJECT, TYPE, TOTALFEE, PAYCOMPANYID, REQTIME, REQCONTENT, ",
            "RESTIME, RESCONTENT, THIRDTRADENO, NOTIFYID",
            "from paygateint",
            "where TRADENO = #{tradeno,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    PayGateint selectByPrimaryKey(String tradeno);

    int updateByExampleSelective(@Param("record") PayGateint record, @Param("example") PayGateintEx example);

    int updateByExample(@Param("record") PayGateint record, @Param("example") PayGateintEx example);

    int updateByPrimaryKeySelective(PayGateint record);

    @Update({
            "update paygateint",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "SUBJECT = #{subject,jdbcType=VARCHAR},",
            "TYPE = #{type,jdbcType=INTEGER},",
            "TOTALFEE = #{totalfee,jdbcType=DECIMAL},",
            "PAYCOMPANYID = #{paycompanyid,jdbcType=INTEGER},",
            "REQTIME = #{reqtime,jdbcType=TIMESTAMP},",
            "REQCONTENT = #{reqcontent,jdbcType=VARCHAR},",
            "RESTIME = #{restime,jdbcType=TIMESTAMP},",
            "RESCONTENT = #{rescontent,jdbcType=VARCHAR},",
            "THIRDTRADENO = #{thirdtradeno,jdbcType=VARCHAR},",
            "NOTIFYID = #{notifyid,jdbcType=VARCHAR}",
            "where TRADENO = #{tradeno,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(PayGateint record);
}
